import { useSelector } from 'react-redux'
import PropTypes from 'prop-types'

const UserName = ({
  userId
}) => {
  const users = useSelector(state => state.users)
  const user = users.find(el => el.id === userId)
  return <span> {user ? user.fullName : userId} </span>
}

UserName.propTypes = {
  userId: PropTypes.string
}

export default UserName